<?php


namespace app\api\controller\v17;


use app\api\controller\v13\Auth2;
use app\common\cachemodel\GoddessBaseInfo;
use think\response\Json;

/**
 * 星文列表
 * @version 2.0.0
 * Class Article
 * @package app\api\controller\v16
 */
class Article extends Auth2
{
    /**
     * @title 获取文章列表
     * @method GET
     * @return array|Json
     * @throws \Exception
     */
    public function index_article()
    {
        //判断是否有公告
        $goddessInfo = (new GoddessBaseInfo())->getInfo(['notice_img3', 'target3', 'link3']);
        $pageData = (new \app\common\cachemodel\Article())->getArticleIndexIds($this->user['id'], 2, 1, 20);
        $article = $pageData['data'];
        if ($goddessInfo['notice_img3'])
        {
            $goddessNotice = [
                'type' => 5,
                'thumb' => $goddessInfo['notice_img3'] ?? '',
                'target' => $goddessInfo['target3'] ?? '',
                'link' => $goddessInfo['link3'] ?? '',
            ];
            array_unshift($article, $goddessNotice);
        }

        return show(config('code.success'), '加载成功', $article);
    }
}
